﻿using FastDev;
using System.Collections.Generic;
using UnityEngine;

public class LeaveAction : GoapAction
{
    public override string Name { get; protected set; } = "Leave";
    public override int Cost { get; protected set; } = 5;
    public override GoapState PreCondition { get; protected set; } = new GoapState(new Dictionary<string, int>() {
        {AIStateKey2.Eat,1 },
    });
    public override GoapState Effect { get; protected set; } = new GoapState(new Dictionary<string, int>()
    {
         {AIStateKey2.Leave,1 },
    });
    public override GoapAgent Agent { get; protected set; }

    private Chair Chair;

    private GameObject Target;
    public LeaveAction(GoapAgent goapAgent) : base(goapAgent)
    {

    }


    public override void OnStart()
    {
        base.OnStart();
        Target = GameObject.FindGameObjectWithTag("LeavePos");
    }

    public override void OnUpdate()
    {
        base.OnUpdate();


        if (Vector3.Distance(Target.transform.position, Agent.transform.position) > 1)
        {
            Agent.transform.Translate((Target.transform.position - Agent.transform.position).normalized * 10 * Time.deltaTime);
            return;
        }

        Agent.GoapState.SetValue(AIStateKey2.Leave, 1);
    }

}